home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
pascal
/
gsdbloo.exe
/
DEMOU002.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-02-20
|
3KB
|
133 lines
Program DemoU002;
{------------------------------------------------------------------------------
DBase File and Memo Builder
Useless Example
Demo Program
Copyright (c) Richard F. Griffin
20 February 1992
102 Molded Stone Pl
Warner Robins, GA 31088
-------------------------------------------------------------
This program creates a dBase file 'MYFILE.DBF with memo file
'MYFILE.DBT'.
-------------------------------------------------------------------------------}
uses
CRT,
DOS,
GS_Date,
GS_Strng,
GS_MakMo,
GS_dBase,
GS_dBFld,
GS_dB3Wk;
type
FldRecPtr = ^FldRecTyp;
FldRecTyp = array[1..GS_dBase_MaxRecField] of GS_dBase_Field;
var
fli : text;
s : string;
i : integer;
gfMemoColl : GS_MakeMemoP;
gfLineName : string[12];
gfBirthDate : string[8];
gfRandomNum : string[12];
f : FldRecPtr;
t : string;
FLoc : integer;
dbx : GSP_dBFld_Objt;
procedure InsertField(s : string; t : char; l,d : integer);
begin
if FLoc >= GS_dBase_MaxRecField then exit;
inc(FLoc);
s := AllCaps(s);
CnvStrToAsc(s,f^[FLoc].FieldName,11);
f^[FLoc].FieldType := t;
f^[FLoc].FieldLen := l;
f^[FLoc].FieldDec := d;
f^[FLoc].FieldAddress := 0;
FillChar(f^[FLoc].Reserved,20,#0);
end;
Function RandString(l,h : integer) : string;
var
v : integer;
g : string;
begin
v := random((h-l)+1);
v := v + l;
str(v,g);
RandString := g;
end;
procedure BuildRecordData;
var
k1 : word;
s1 : string[5];
begin
str(i, gfLineName);
gfLineName := 'Line ' + gfLineName;
k1 := random(25);
gfBirthDate := GS_Date_dBStor(GS_Date_Curr - k1);
k1 := random(2);
if k1 = 0 then gfRandomNum := '-' else gfRandomNum := '';
s1 := RandString(0,30000);
while length(s1) < 5 do s1 := s1+'0';
gfRandomNum := gfRandomNum + RandString(0,30000) + '.' + s1;
while length(gfRandomNum) < 12 do gfRandomNum := ' ' + gfRandomNum;
gfMemoColl^.ResetMemoData;
readln(fli, s);
gfMemoColl^.InsertMemoData(s+#13#10);
end;
{--- Main Program ---}
begin
{Create new dBase file}
New(f);
FLoc := 0;
InsertField('LINENAME','C',30,0);
InsertField('BIRTHDATE','D',8,0);
InsertField('RANDOMNUM','N',12,5);
InsertField('COMMENTS','M',10,0);
GS_dB3_Build('MyFile',f,FLoc);
dispose(f);
{Add records to the file}
New(dbx, Init('MyFile'));
dbx^.Open;
gfMemoColl := New (GS_MakeMemoP, Init(dbx,8192));
randomize;
assign(fli,'wisdom.fil');
reset(fli);
for i := 1 to 20 do
begin
BuildRecordData;
dbx^.Blank;
dbx^.FieldPut('LINENAME',gfLineName);
dbx^.FieldPut('BIRTHDATE',gfBirthDate);
dbx^.FieldPut('RANDOMNUM',gfRandomNum);
dbx^.FieldPut('COMMENTS',gfMemoColl^.WriteMemoRecord);
dbx^.Append;
end;
{Dispose of objects (also closes the files}
Dispose(gfMemoColl, Done);
Dispose(dbx, Done);
close(fli);
end.